package cn.edu.cug.cs.gtl.plugins.catalog;

import cn.edu.cug.cs.gtl.apis.ui.AbstractApplication;
import cn.edu.cug.cs.gtl.apis.ui.actions.AbstractActions;
import cn.edu.cug.cs.gtl.apis.ui.actions.CatalogActions;
import cn.edu.cug.cs.gtl.plugins.catalog.tree.*;
import org.pf4j.Extension;
import org.pf4j.Plugin;

public class CatalogPlugin extends Plugin {


    public CatalogPlugin() {
        super();
    }


    @Override
    public void start() {
        super.start();
    }


    @Override
    public void stop() {
        super.stop();
    }


    @Override
    public void delete() {
        super.delete();
    }

    //CatalogActionsImpl类从AbstractActions类继承并实现CatalogActions接口，需要添加@Extension注解并实现initialize接口，这个就是插件。
    //CatalogActions接口继承自Actions接口，Actions接口继承自ExtensionPoint类，这个类是pf4j使用时要求继承的类，在Actions接口中定义了initialize方法
    @Extension
    public static class CatalogActionsImpl extends AbstractActions implements CatalogActions {

        @Override
        public void initialize(AbstractApplication theApp) {
            AddChildCatalogAction newCatalogAction = new AddChildCatalogAction();
            newCatalogAction.initialize(theApp);
            addAction(newCatalogAction);

            AddChildGroupAction newGroupAction = new AddChildGroupAction();
            newGroupAction.initialize(theApp);
            addAction(newGroupAction);

            AddNewItemAction newItemAction = new AddNewItemAction();
            newItemAction.initialize(theApp);
            addAction(newItemAction);

            AddExistItemAction existItemAction = new AddExistItemAction();
            existItemAction.initialize(theApp);
            addAction(existItemAction);

            DeleteSelectCatalogAction deleteSelectCatalogAction = new DeleteSelectCatalogAction();
            deleteSelectCatalogAction.initialize(theApp);
            addAction(deleteSelectCatalogAction);

            DeleteSelectGroupAction deleteSelectGroupAction = new DeleteSelectGroupAction();
            deleteSelectGroupAction.initialize(theApp);
            addAction(deleteSelectGroupAction);

            DeleteSelectItemAction deleteItemAction = new DeleteSelectItemAction();
            deleteSelectCatalogAction.initialize(theApp);
            addAction(deleteItemAction);

            EditSelectCatalogAction editSelectCatalogAction = new EditSelectCatalogAction();
            editSelectCatalogAction.initialize(theApp);
            addAction(editSelectCatalogAction);

            EditSelectGroupAction editGroupAction = new EditSelectGroupAction();
            editGroupAction.initialize(theApp);
            addAction(editGroupAction);

            EditSelectItemAction editItemAction = new EditSelectItemAction();
            editItemAction.initialize(theApp);
            addAction(editItemAction);
        }
    }
}
